<template>
  <div>
<div class="header1">
      <div>
        <div class="header_top">
            <div v-if="this.$store.state.islogin==0">   
                <router-link to="/login">请登录 </router-link>
                <router-link to="/register">免费注册</router-link>    
            </div>
            <div v-else>
                <router-link to="/">{{this.$store.state.user.uname}}</router-link>
                <span @click="login_out()" class="login_out">退出</span>
                <router-link to="/">我的订单</router-link>
            </div>
            <div>
                <ul>
                    <li class="drop">
                      <router-link to="/" class="drop_a">我的信息</router-link>
                      <span></span>
                        <div class="drop-content">
                          <div><router-link to="/">我的订单</router-link></div>
                          <div><router-link to="/">我的地址</router-link></div>
                          <div><router-link to="/">我的收藏</router-link></div>
                        </div>
                        <div></div>
                    </li>  
                    <li><router-link to="/">手机端</router-link></li>
                    <li><router-link to="/">消费者告知书</router-link></li>
                </ul>         
            </div>  
        </div>
        <div class="header_middle">
            <div>
                <img src="/img/index/logo.gif">
            </div>
            <div>
                <div class="_input">
                    <input type="text" v-model="keyword">
                    <!-- <span @click="_search(keyword)">搜 索</span> -->
                    <router-link :to="{path:'/list',query:{keyword:keyword,page:1}}" class="search">搜 索</router-link>
                </div>
                <div class="router_link">
                    <router-link to="/" v-for="(name,i) of arr1" :key="i">{{name}}</router-link>
                </div>
            </div>
            <div @click="toCart" class="xiaoshou">
                <div class="cart_icon"></div>
                <div>购物车({{cartcount}})</div>
            </div>
        </div>
        <div class="header_bottom">
            <div>
                <div>
                    <ul class="ul_1">
                        <li>
                            所有商品分类
                            <ul class="ul_11">
                                <li class="ul_11_li_1">
                                    <div>
                                      <p class="font_15">母婴专区</p>
                                      <p class="font_12 color_gray">奶粉 营养品 辅食 宝宝用品</p>  
                                    </div>
                                    <ul class="ul_111">
                                        <li>
                                            <router-link to="#">奶粉</router-link>
                                            <router-link to="#">营养品</router-link>
                                            <router-link to="#">辅食</router-link>
                                            <router-link to="#">宝宝用品</router-link>
                                        </li>
                                    </ul>
                                </li>
                                <li class="ul_11_li_2">
                                    <div>
                                      <p class="font_15">食品保健</p>
                                      <p class="font_12 color_gray">Swisse Brauer Life Space</p>  
                                    </div>   
                                    <ul class="ul_112">
                                            <router-link to="#">Swisse</router-link>
                                            <router-link to="#">Brauer</router-link>
                                            <router-link to="#">Life</router-link>
                                            <router-link to="#">Space</router-link>
                                    </ul>
                                </li>
                                <li class="ul_11_li_3">
                                    <div>   
                                      <p class="font_15">美妆个护</p>
                                      <p class="font_12 color_gray">JM 资生堂 蒂佳婷 兰蔻</p>  
                                    </div>
                                        <ul class="ul_113">
                                            <router-link to="#">JM</router-link>
                                            <router-link to="#">资生堂</router-link>
                                            <router-link to="#">蒂佳婷</router-link>
                                            <router-link to="#">兰蔻</router-link>
                                        </ul>
                                </li>
                                <li class="ul_11_li_4">
                                    <div>   
                                      <p class="font_15">时尚轻奢</p>
                                      <p class="font_12 color_gray">碧然德 阿玛尼 DW 小CK</p>  
                                    </div>
                                        <ul class="ul_114">
                                            <router-link to="#">碧然德</router-link>
                                            <router-link to="#">阿玛尼</router-link>
                                            <router-link to="#">DW</router-link>
                                            <router-link to="#">小CK</router-link>
                                        </ul>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
                <div>
                    <ul class="nav2">
                        <li><router-link to="/" class="blankColor">首页</router-link></li>
                        <li><router-link :to="{path:'/list',query:{classi:'mu_all',page:1}}" class="blankColor"><span>母婴专区</span></router-link></li>
                        <li><router-link :to="{path:'/list',query:{classi:'bao_all',page:1}}" class="blankColor"><span>食品保健</span></router-link></li>
                        <li><router-link :to="{path:'/list',query:{classi:'mei_all',page:1}}" class="blankColor"><span>美妆个护</span></router-link></li>
                        <li><router-link :to="{path:'/list',query:{classi:'shi_all',page:1}}" class="blankColor"><span>时尚轻奢</span></router-link></li>
                        <li><router-link to="/" class="blankColor"><span>限时抢购</span></router-link></li>
                        <li><router-link to="/" class="blankColor"><span>特价专区</span></router-link></li>
                    </ul>
                </div>
                <div>
                    <ul class="nav3">
                        <li><router-link to="/"><div class="zheng"></div>正品保障</router-link></li>
                        <li><router-link to="/"><div class="mian"></div>含税包邮</router-link></li>
                        <li><router-link to="/"><div class="kuai"></div>顶尖物流</router-link></li>
                    </ul>
                </div>    
            </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState,mapGetters } from 'vuex'
export default {
    data(){
        return {
            keyword:'',
            arr1:["澳洲","德国","赫莲娜","喜宝","A2","牛栏","韩后","雀巢","美素","颖睿","兰蔻","阿玛尼","美赞臣"],
            page:1,
        }
    },
    methods:{
        login_out(){
            this.$store.state.islogin=0
            // sessionStorage.clear();            //清空当前网站下的所有 WebStorage 数据
            sessionStorage.removeItem("islogin",1)//删除 WebStorage 中指定的数据
            },
        toCart(){
            this.$router.push('/cart')
        },
    },
    computed:{
       ...mapState(['count2']),
       cartcount(){
           return this.count2
       }
    }
}
</script>

<style scoped>
.ul_1{
    width: 230px;
    height: 40px;
    margin-top: 10px;
    line-height: 40px;
    color: #fff;
    font-size: 14px;
    background-color: #52cbf6;
    position: relative;
}
.ul_1:hover .ul_11{
    display: block;
    z-index: 30;
}
.ul_11{
    display: none;
    height: 330px;
    background-color:#333;
    text-align: left;
    position: relative;
    z-index: 100;
}
.ul_11_li_1:hover .ul_111,.ul_11_li_2:hover .ul_112,.ul_11_li_3:hover .ul_113,.ul_11_li_4:hover .ul_114{ 
    display: block;
    position: absolute;
    left: 230px;
    width: 300px;
    top: 0px;
    height: 328px;
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 3px 3px 5px #ccc;
    border-left: 0;
    z-index: 35;
}
.ul_11_li_1:hover,.ul_11_li_2:hover,.ul_11_li_3:hover,.ul_11_li_4:hover{
    background-color: #fff;
    color: #333;
    border-left: 2px solid #52cbf6;
}
.ul_11_li_1,.ul_11_li_2,.ul_11_li_3,.ul_11_li_4{
    padding: 0 20px;
}
.ul_111,.ul_112,.ul_113,.ul_114{
    display: none;
}
.ul_111 a,.ul_112 a,.ul_113 a,.ul_114 a {
    color: #666;
    margin-left: 20px;
}
.ul_111 a:hover,.ul_112 a:hover,.ul_113 a:hover,.ul_114 a:hover {
    color: #E73736;
}
.font_12{
    font-size: 12px;
    margin-top: -12px;
}
.font_15{
    font-size: 15px;
}
.color_gray{
    color: #999;
}
  .header1{
    height: 195px; 
    padding: 0;
    margin: 0;
    font-size: 12px;
  }
  .header_top{
      height: 35px;
      background: #3e3a39;
      line-height: 36px;
      display: flex;
  }
  .header_top>div:nth-child(1){
      margin-left: 17.5%;
      margin-right: -15px;
  }
  .header_top .drop span{
      display:inline-block ;
      width: 11px;
      height: 11px;
      background-image: url("/img/index/site-bg.png");
      margin-top: 12px;
      
  }
  .header_top .drop:hover  span{
    background-image: url("/img/index/site-bg.png");
    background-position: 0 -10px;
  }
  .header_top a{
      color: #ccc;
      margin: 0 6px;
  }
  .login_out{
    color:#ccc;
    cursor: pointer;
  }
  .header_top a:hover{
      color: #999;
  }
  .header_top>div:nth-child(2){
      margin-left: 47%;
  }
  .header_top ul{
      display: flex;
  }
  .header_top .drop{
    width: 88px;
    height: 35px;
    position: relative;
  }
  .header_top .drop:hover .drop-content{
    display: block;
  }
  .drop-content{
    display: none;
    margin-top: -2px;
    height: 80px;
    border: 1px solid #ddd;
    background-color: #fff;
    padding-top: 10px;
  }
  .drop-content div{
    margin-top: -10px;
  }
  .drop-content div a{
    color: #000;
  }
  .drop-content div a:hover{
    color: #52cbf6;
  }
  .xiaoshou{
      cursor: pointer;
  }
  .header_middle{
      display: flex;
      margin:15px 0 5px 0;
  }
  .header_middle>div:nth-child(1){
      margin-left: 18%;
  }
  .header_middle>div:nth-child(2){
      margin:15px 0 0 8%;
  }
  ._input{
      display: flex;
      margin-left: 46px;
  }
  .header_middle>div:nth-child(2) input{
    width: 310px;
    padding: 10px;
    border: 1px solid #42a5ee;
    color: #888;
  }
  .header_middle>div:nth-child(2)>div:nth-child(1)>a{
      display: inline-block;
      background-color: #42a5ee;
      padding: 10px 0 12px 0;
      width: 82px;
      color: white;
      font-size: 14px;
      font-weight: bold;
      cursor: pointer;
  }
  .header_middle>div:nth-child(2)>div:nth-child(2){
      margin:10px 0 0 36px;
      width: 470px;
  }
  .header_middle>div:nth-child(2)>div:nth-child(2) a{
      color: #333;
      margin-left: 10px;
  }
  .header_middle>div:nth-child(2)>div:nth-child(2) a:hover{
    color: #42a5ee;
  }
  .header_middle>div:nth-child(3){
      margin:15px 0 0 8%;
      width: 150px;
      height: 40px;
      background-color: #E73736;
      color: white;
      display: flex;
      line-height: 42px;  
  }
  .header_middle .cart_icon{
      width: 20px;
      height: 30px;
      background-image: url("/img/index/common-icon.png");
      background-position:270px 0px;
      margin:4px 6px 0 36px;
  }


  .header_bottom{
      width: 1300px;
      margin-left: 18%;
  }
  .header_bottom>div:nth-child(1){
      display: flex;
  }
  .header_bottom .nav2 li a:hover{
      color: #e73736 !important;
  }
  .header_bottom .nav2 {
      width: 700px;
      display: flex;
      color: #333;
      font-size: 14px;
      justify-content: space-around;
      line-height: 60px;
  }
  .header_bottom .nav3 {
        justify-content: space-around;
        align-content: center;
        width: 270px;
        display: flex;
        line-height: 60px;
    }
  .header_bottom .nav3 a{
      color: #999;
    }
  .zheng,.mian,.kuai{
      width: 24px;
      height: 24px;
      float: left;
  }

   .blankColor{
      color: #333 !important;
  } 
  .zheng{
      background-image: url("/img/index/header.png");
      background-position: -10px -555px;
      margin-top: 18px;
  }
  .mian{
      background-image: url("/img/index/header.png");
      background-position: -10px -405px;
      margin-top: 18px; 
  }
  .kuai{
      background-image: url("/img/index/header.png");
      background-position: -10px -228px;
      margin-top: 18px; 
  }
</style>
